<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:t="http://myfaces.apache.org/tomahawk"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:body>
    	<ui:composition template="./templates/framework.xhtml">
			<ui:define name="content">
				<ui:fragment rendered="#{sessionBean.keeBookSelected}">
					<ui:include src="./templates/header.xhtml">
						<ui:param name="text" value="#{i18n['generic.back']}" />
						<ui:param name="link" value="index.xhtml" />
					</ui:include>
				</ui:fragment>
				<ui:fragment rendered="#{not sessionBean.keeBookSelected}">
					<ui:include src="./templates/header.xhtml">
						<ui:param name="text" value="#{i18n['selectBook.head']}" />
					</ui:include>
				</ui:fragment>
				<script type="text/javascript">
					var keeBookSalts = new Object();
					<ui:repeat value="#{selectKeeBookBean.boxes}" var="keeBook">
						keeBookSalts['#{keeBook.exposableId}'] = '#{keeBook.salt}';
					</ui:repeat>
				</script>
				<h:form onsubmit="updateSelectKeeBookForm()" id="selectKeeBookForm" styleClass="primary">
					<div>
						<h:outputLabel for="keeBookId" value="#{i18n['generic.book']}" />
						<h:selectOneMenu id="keeBookId" value="#{selectKeeBookBean.keeBookId}" required="true" requiredMessage="#{i18n['generic.valueRequired']}" validator="#{selectKeeBookBean.validateKeeBookId}">
							<f:selectItems value="#{selectKeeBookBean.boxes}" var="keeBook" itemLabel="#{keeBook.name}" itemValue="#{keeBook.exposableId}" />
						</h:selectOneMenu>
						<span class="error"><h:message for="keeBookId" /></span>
					</div>
					<div>
						<h:outputLabel for="masterPassword" value="#{i18n['generic.password']}" />
						<h:inputSecret id="masterPassword" autocomplete="off" validator="#{selectKeeBookBean.validateMasterPassword}" required="true" requiredMessage="#{i18n['generic.valueRequired']}" value="#{selectKeeBookBean.masterPassword}" styleClass="focus" />
						<span class="error"><h:message for="masterPassword" /></span>
					</div>
					<div class="buttons">
						<h:commandButton type="submit" value="#{i18n['selectBook.select']}" action="#{selectKeeBookBean.select}" />
						<input type="button" value="#{i18n['selectBook.create']}" onclick="location.href='createkeebook.xhtml'" />
						<ui:fragment rendered="#{sessionBean.keeBookSelected}">
							<input type="button" value="#{i18n['generic.cancel']}" onclick="location.href='index.xhtml'" />
						</ui:fragment>
					</div>
				</h:form>
			</ui:define>
		</ui:composition>
    </h:body>
</html>